#ifndef __RENDER_MESH_H__
#define __RENDER_MESH_H__

#pragma once

#include "GeometryData.h"

namespace Nezha
{
	/** single mesh object. */
	class GRAPHICS_ENTRY RenderMesh : public Refable
	{
	public:
		virtual ~RenderMesh();

		virtual GeometryType getType() const = 0;

		// TODO bounds?

		/**
		@remarks
			this will cause the buffers to be locked, use endAccess() to release the lock after you finish your operation.
		*/
		VertexBufferAccessor* beginAccess();

		void endAccess();

		const GeometryData* getDataRaw() const
		{
			return mGeometryDataPtr.ptr();
		}

		GeometryData* getDataRaw()
		{
			return mGeometryDataPtr.get();
		}

		RenderMesh(GeometryData* gd);
	protected:
		virtual void updateNormals() = 0;
		virtual void updateTangents(u32 tangentSpace) = 0;

		GeometryDataPtr mGeometryDataPtr;
		VertexBufferAccessor* mVBAccessor;
	};

	typedef RefCountedPtr<RenderMesh>::Default RenderMeshPtr;

}//end namespace Nezha

#endif //end __RENDER_MESH_H__